package bankapplication.com.acme.bankapp.service.bank;

import java.util.Iterator;
import java.util.zip.DataFormatException;

import bankapplication.com.acme.bankapp.domain.bank.Account;
import bankapplication.com.acme.bankapp.domain.bank.Bank;
import bankapplication.com.acme.bankapp.domain.bank.Client;
import bankapplication.com.acme.exceptions.*;

public class BankService {
  public static void addClient(Bank bank, Client client) throws ClientExistsException, DataFormatException{
    BankDataLoaderService.saveBank(bank);
    bank.addClient(client);
  }
  public static void printMaximumAmountToWithDraw(Bank bank) throws DataFormatException {
    Iterator<Client> clientiter = bank.getClients().iterator();
    while(clientiter.hasNext()){
      Iterator<Account> accountiter = clientiter.next().getAcconts().iterator();
      while(accountiter.hasNext()){
        System.out.println(accountiter.next().maximumAmountToWithdraw());
      }
    }
  }
}
